import { CHANGE_TAB } from "../actions/actionTypes";
import TABKEY from '../config/index.js';

const initState = {
    tabs: [
        {
            name: '点菜',
            key: TABKEY.menu
        },
        {
            name: '评价',
            key: TABKEY.comment
        },
        {
            name: '商家',
            key: TABKEY.restanurant
        }
    ],
    activeKey: TABKEY.menu
};


const handleChangeTab = (state, action) => {
    return { ...state, activeKey: action.obj.activeKey }
}

const changeTabReducer = (state = initState, action) => {
    switch(action.type) {
        case CHANGE_TAB:
            return handleChangeTab(state, action);
        default:
            return state;
    }
}

export default changeTabReducer


